package com.base.commonlib.base;

import android.view.View;

import com.base.commonlib.base.presenter.PresenterI;
import com.base.commonlib.base.view.ViewI;


/**
 * Date：2019/4/9 下午4:50
 * Creator：arvin
 * Des：
 */

public abstract class BaseViewFragment<H extends PresenterI> extends BaseFragment implements ViewI {

    protected H mPresenter;
    @Override
    public void showPb() {
        if(mContext instanceof BaseSimpleActivity)
        {
            ((BaseSimpleActivity)mContext).showPb();
        }else if(mContext instanceof BaseViewActivity)
        {
            ((BaseViewActivity)mContext).showPb();
        }
    }

    @Override
    public void hidePb() {
        if(mContext instanceof BaseSimpleActivity)
        {
            ((BaseSimpleActivity)mContext).hidePb();
        }else if(mContext instanceof BaseViewActivity)
        {
            ((BaseViewActivity)mContext).hidePb();
        }
    }

    @Override
    public void showMes(String msg) {
        showMesB(msg);
    }

    @Override
    public void showMes_action(String msg, String action, View.OnClickListener listener) {
        showMesWActionB(msg,action,listener);
    }

    @Override
    public void showError() {
        if(mContext instanceof BaseSimpleActivity)
        {
            ((BaseSimpleActivity)mContext).showError();
        }else if(mContext instanceof BaseViewActivity)
        {
            ((BaseViewActivity)mContext).showError();
        }
    }

    @Override
    public void showPb_mes(String mes) {
        if(mContext instanceof BaseSimpleActivity)
        {
            ((BaseSimpleActivity)mContext).showPb_mes(mes);
        }else if(mContext instanceof BaseViewActivity)
        {
            ((BaseViewActivity)mContext).showPb_mes(mes);
        }
    }

    @Override
    public void hidePb_mes() {
        if(mContext instanceof BaseSimpleActivity)
        {
            ((BaseSimpleActivity)mContext).hidePb_mes();
        }else if(mContext instanceof BaseViewActivity)
        {
            ((BaseViewActivity)mContext).hidePb_mes();
        }
    }

    @Override
    public void onLogin() {
        super.onLogin();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if(mPresenter!=null)
        {
            mPresenter.release();
        }

    }
}
